import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/**
 *
 * @author Marc
 */
public class Test extends javax.swing.JFrame implements MouseListener{
    String txt = "";

    public Test() {
        initComponents();
        jTable1.addMouseListener(this);
        addMouseListener(this);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"-", "DP1", "DP2", "DP3"},
                {"FR1", null, null, null},
                {"FR2", null, null, null},
                {"FR3", null, null, null}
            },
            new String [] {
                "-", "-", "-", "-"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(15, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void mouseClicked(MouseEvent e) {
        Point p = e.getPoint();
        int y = jTable1.rowAtPoint(p);
        int x = jTable1.columnAtPoint(p);
        changeProperty(x, y);
    }

    public void mousePressed(MouseEvent e) {
        // Wenn notwenig noch implementieren
    }

    public void mouseReleased(MouseEvent e) {
        // Wenn notwenig noch implementieren
    }

    public void mouseEntered(MouseEvent e) {
        // Wenn notwenig noch implementieren
    }

    public void mouseExited(MouseEvent e) {
        // Wenn notwenig noch implementieren
    }

    private void changeProperty(int x, int y) {
        txt = String.valueOf(jTable1.getValueAt(y, x));
        
        if(txt == null || txt.equals("") || txt.equals("null")){
            jTable1.setValueAt("X", y, x);
            txt = "X";
        }else if(txt.equals("X")){
            jTable1.setValueAt("+", y, x);
        }else if(txt.equals("+")){
            jTable1.setValueAt("O", y, x);
        }else if(txt.equals("O")){
            jTable1.setValueAt("", y, x);
        }else{
            System.out.println("Problem");
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Test().setVisible(true);
            }
        });
    }
}
